import { rawRequestClient } from '#/api/request';

// 获取组织列表
export function getOrganizationList(params?: {
  page?: number;
  size?: number;
  name?: string;
  type?: string;
  parentId?: number;
}) {
  return rawRequestClient.get(`${import.meta.env.VITE_AUTH_SERVER}/groups`, { params });
}

// 创建组织
export function createOrganization(data: {
  name: string;
  description?: string;
  parentId?: number;
  type?: string;
}) {
  return rawRequestClient.post(`${import.meta.env.VITE_AUTH_SERVER}/groups`, data);
}

// 获取组织详情
export function getOrganizationDetail(id: number) {
  return rawRequestClient.get(`${import.meta.env.VITE_AUTH_SERVER}/groups/${id}`);
}

// 更新组织
export function updateOrganization(id: number, data: {
  name?: string;
  description?: string;
  parentId?: number;
  type?: string;
}) {
  return rawRequestClient.put(`${import.meta.env.VITE_AUTH_SERVER}/groups/${id}`, data);
}

// 删除组织
export function deleteOrganization(id: number) {
  return rawRequestClient.delete(`${import.meta.env.VITE_AUTH_SERVER}/groups/${id}`);
}
